@extends('layouts.application')

@section('content')

    <div class="admin-content">

        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf">
                    <strong class="am-text-primary am-text-lg">编辑广告</strong> /
                    <small>Edit Advert</small>
                </div>
            </div>


            <hr>

            <div class="am-tabs am-margin">
                @include('layouts.shared._flash')


                <form class="am-form" action="{{route('ad.advert.update',$advert->id)}}" method="post">

                    {{csrf_field()}}
                    {{method_field('PUT')}}

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            广告标题
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            <input type="text" class="am-input-sm" name="title" placeholder="请输入品牌名称" value="{{$advert->title}}">
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">*必填，不可重复</div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            广告地址
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            <input type="text" class="am-input-sm" name="url" placeholder="请输入广告地址" value="{{$advert->url}}">
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">*必填，不可重复</div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            所属栏目
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <select  data-am-selected="{btnWidth: '100%',  btnStyle: 'secondary',
                                    btnSize: 'sm', maxHeight: 360, searchBox: 1}" name="category_id">
                                @foreach($categories as $category)
                                    <option value="{{$category->id}}"
                                    @if($category->id == $advert->category_id) selected @endif>{{$category->name}}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            缩略图
                        </div>

                        <div class="am-u-sm-8 am-u-md-8 am-u-end col-end">
                            <div class="am-form-group am-form-file new_thumb">
                                <button type="button" class="am-btn am-btn-success am-btn-sm">
                                    <i class="am-icon-cloud-upload" id="loading"></i> 上传广告图
                                </button>
                                <input type="file" id="image_upload">
                                <input type="hidden" name="thumb" value="{{$advert->thumb}}">
                            </div>

                            <hr data-am-widget="divider" style="" class="am-divider am-divider-dashed"/>

                            <div>
                                <img src="{{$advert->thumb}}" id="img_show" style="max-height: 200px;">
                            </div>
                        </div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            排序
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            <input type="text" class="am-input-sm" name="sort_order" placeholder="排序数最大99" value="{{$advert->sort_order}}">
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">选填</div>
                    </div>



                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            内容描述
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <textarea rows="4" placeholder="广告描述" name="description" >{{$advert->description}}</textarea>
                        </div>
                    </div>

                    <div class="am-margin">
                        <button type="submit" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
                        <a href="{{route('ad.advert.index')}}" class="am-btn am-btn-primary am-btn-xs">返回</a>
                    </div>
                </form>
            </div>
        </div>

        <footer class="admin-content-footer">
            <hr>
            <p class="am-padding-left">© 2017-06.</p>
        </footer>
    </div>

@endsection

@section('js')
    <script src="/vendor/html5-fileupload/jquery.html5-fileupload.js"></script>
    <script src="/js/upload.js"></script>
@endsection
